package com.doit.demo04;

import java.util.*;
import java.util.stream.Stream;

public class test02 {
    public static void main(String[] args) {
        List<String>list = new ArrayList<>();
        //list->Stream
        Stream<String> stream = list.stream();

        Set<String> set = new HashSet<>();
        //set->Stream
        Stream<String> stream1 = set.stream();

        Map<String,Integer>map = new TreeMap<>();
        //map->Stream 比较繁琐 需要一点一点的保存
        Set<String> set1 = map.keySet();
        Stream<String> stream2 = set1.stream(); //保存key
        Collection<Integer> values = map.values();
        Stream<Integer> stream3 = values.stream();//保存value

        Set<Map.Entry<String, Integer>> entries = map.entrySet();
        Stream<Map.Entry<String, Integer>> stream4 = entries.stream();//保存键值对

        //数组转换为Stream
        String[]arr={"aa","bb"};
        Stream<String> arr2 = Stream.of(arr);

        Integer[] arr21 = {3,8,2,5,0};
        Stream<Integer> arr1 = Stream.of(arr21);
        arr1.forEach(s-> System.out.println(s));

        Stream<String> aa = Stream.of("aa", "bb");
        aa.forEach(s -> System.out.println(s));
    }
}
